class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-08-13",
      revision: "0025db717fb94a3eceb0510403ceae97276c65dc"
  version "2021-08-13"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "59a19a99b15e89d52026aa901c1092cc9c448c88772558704aec43c97903fd46"
    sha256 cellar: :any_skip_relocation, big_sur:       "149f5ddf79eca1a484a6fe08458794842056b5ed895084da7adbac76addaf3f0"
    sha256 cellar: :any_skip_relocation, catalina:      "e49640949d1ce4f51ab7702a37330f7821363d5f97054e65ed9f444d4e40511c"
    sha256 cellar: :any_skip_relocation, mojave:        "49202665c6efa2df93a4ed5e753dc2a28c6a8b8b3f8939c140245ec5406397d5"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "080fcf80803d260da1d1c6e3f288ac8342b7f83761d00387bd03c3c2617e0610"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
